<?php

	Class Conexao {
 
    var $host;
    var $user;
    var $pass;
    var $dbname;
    var $data;
    var $db;
    var $saida;
    var $status;
    var $entrada;
 
    function Conexao() {
         
    }
 
    public function conecta() {
        $this->status = 0;
        /*$this->host = "mysql.hostinger.com.br";
        $this->user = "u467623816_root";
        $this->pass = "IWvhmmv1OX";
        $this->dbname = "u467623816_01";*/
		$this->host = "localhost:3306";
        $this->user = "root";
        $this->pass = "programacao&132";
        $this->dbname = "u467623816_01";
        $this->db = new mysqli($this->host, $this->user, $this->pass, $this->dbname);
 
        if (!$this->db) {
//  echo "Erro ao conectar no banco".trigger_error(mysql_error(),E_USER_ERROR);
            echo "Erro ao conectar no banco" . mysql_error();
        } else {
            //echo "Conectado no banco";
            $this->status = 1;
        }
		
		return $this->db;
    }
 
    public function executeQuery($query) {
        if ($this->status == 1) {
            //echo "lista...";
            if ($this->saida = $this->db->prepare($query)) {
                // echo 'Rs loaded';
				$this->saida->execute();
                return $this->saida;
            } else {
                echo "<pre class=\"error\">";
                echo "SQL ERROR: " . mysql_error();
                echo "SQL : " . $query;
                echo "</pre>";
                desconecta();
            }
        }
    }
 
    public function executeUpdate($query) {
        if ($this->status == 1) {
            if ($this->entrada = mysql_query($query)) {
                return true;
            } else {
                echo "<pre class=\"error\">";
                echo "SQL ERROR: " . mysql_error();
                echo "</pre>";
                desconecta();
                return false;
            }
        }
    }
 
    function desconecta() {
        return $this->db->close();
    }
 
}
	
?>